package com.gxa.autoparts.admin.controller;

import com.gxa.autoparts.admin.mapper.GoodsMapper;
import com.gxa.autoparts.admin.mapper.GoodsRemoteMapper;
import com.gxa.autoparts.core.common.JsonResult;
import com.gxa.autoparts.core.pojo.Goods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author ：looker
 * @date ：Created in 2022/1/8 15:37
 * good相关业务，前台商品缓存使用
 */
@RestController
@RequestMapping("/goodsRemote")
public class GoodsRemoteController {


    @Resource
    GoodsMapper goodsMapper;

    @PostMapping("/getById")
    public Map getGoodsById(Long id){
        Goods goods = goodsMapper.selectByPrimaryKey(id);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(goods);
        return jsonResult.getDataMap();
    }
}
